package sqlTest;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.*;
public class sqlTest1 {
	public static void main(String[] args) {		
		try {
			Class.forName("oracle.jdbc.driver.OracleDriver");
			Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@cmgcdb02:1521:cmctst","dbakm","kmdba");
			Statement s = conn.createStatement();
			String sql="select a.emp_no,a.emp_name, b.dept_name from cmc_employee a,cmc_department b where a.emp_unit=b.dept_no and trim(b.invalid_date) is null and trim(a.emp_leave_date)is null and a.dept_level1='A124' order by dept_name,emp_no";
			ResultSet rs=s.executeQuery(sql);
			Vector v=new Vector();
			int numColumns = rs.getMetaData().getColumnCount();
			
			String[] aRow;			
			while(rs.next())
			{
				aRow = new String[numColumns];
				for (int i = 0; i < numColumns; i++)
					aRow[i] = rs.getString(i+1);					
				v.add(aRow);
			}
			
			s.close();
			conn.close();
			
			String a[]=(String[])v.get(1);
			for(int i=0;i<a.length;i++)
				System.out.println(a[i]);
			
		}catch(Exception e){
			System.out.println(e.toString());				
		}
	}
}
